package asteroids.launcher;

import java.awt.Dimension;
import java.awt.Graphics2D;

import javax.swing.JOptionPane;

import asteroids.scenes.Level;

import com.uqbar.vainilla.DesktopGameLauncher;
import com.uqbar.vainilla.Game;

public class AsteroidsGame extends Game {
	
	private Level level;

	@Override
	protected void initializeResources() {
		this.setLevel(new Level());
	}

	@Override
	protected void setUpScenes() {
		this.setCurrentScene(this.getLevel());
	}

	@Override
	public Dimension getDisplaySize() {
		return new Dimension(1000, 600);
	}

	@Override
	public String getTitle() {
		return "Asteroids";
	}
	
	@Override
	public void takeStep(Graphics2D graphics) {
		super.takeStep(graphics);
		
		if (this.getLevel().isSpaceShipDestroyed())
			this.showMessage("Explotaste.");
		
		if (this.getLevel().isAllAsteroidsDestroyed())
			this.showMessage("¡Ganaste!");
	}

	private void showMessage(String message) {
		JOptionPane.showMessageDialog(null, message);
		System.exit(0);
	}
	
	public static void main(String[] args) {
		new DesktopGameLauncher(new AsteroidsGame()).launch();
	}

	
	
	
	public Level getLevel() {
		return level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}
}
